//
//  MainPlayViewController.m
//  工作测试
//
//  Created by 华夏安科 on 2018/10/16.
//  Copyright © 2018年 华夏安科. All rights reserved.
//

#import "MainPlayViewController.h"
#import <IJKMediaFramework/IJKMediaFramework.h>

@interface MainPlayViewController ()
@property(nonatomic,strong)IJKFFMoviePlayerController *player;

@end

@implementation MainPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *urlStr = @"http:\/\/hdl0901.plures.net\/lzlive\/xiaotianbing1.flv?wsSecret=e32a60c843d5b59b51c28f987e85cfa7&wsTime=5bc59bb0";
    //    [IJKVideoViewController presentFromViewController:self withTitle:[NSString stringWithFormat:@"URL: %@", url] URL:url completion:^{
    //        //            [self.navigationController popViewControllerAnimated:NO];
    //    }];
    IJKFFMoviePlayerController *playerVc = [[IJKFFMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:urlStr] withOptions:nil];
    // 强引用，反正被销毁
    _player = playerVc;
    self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    self.player.scalingMode = IJKMPMovieScalingModeAspectFit;
    self.player.shouldAutoplay = YES;
    
    self.view.autoresizesSubviews = YES;
    self.player.view.frame = self.view.bounds;
    [self.view addSubview:self.player.view];
    [self.player prepareToPlay ];

    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self.player play];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
